package com.cn.shuangzi.ad.custom;

import android.content.Context;

import com.bytedance.msdk.api.v2.ad.custom.bean.GMCustomInitConfig;
import com.bytedance.msdk.api.v2.ad.custom.init.GMCustomAdapterConfiguration;
import com.cn.shuangzi.ad.ADManager;
import com.cn.shuangzi.ad.util.ADUtil;
import com.cn.shuangzi.ad.util.ThreadUtils;
import com.cn.shuangzi.util.SZUtil;
import com.qq.e.comm.managers.GDTAdSdk;
import com.qq.e.comm.managers.setting.GlobalSetting;
import com.qq.e.comm.managers.status.SDKStatus;

import java.util.Map;

/**
 * YLH 自定义初始化类
 */
public class YlhCustomerConfig extends GMCustomAdapterConfiguration {

    @Override
    public void initializeADN(final Context context, final GMCustomInitConfig gmCustomConfig, Map<String, Object> localExtra) {
        /**
         * 在子线程中进行初始化
         */
        ThreadUtils.runOnThreadPool(new Runnable() {
            @Override
            public void run() {
                GlobalSetting.setChannel(ADManager.getGDTChannelCode());
//                boolean isCanUsePhone = ADUtil.isCanUsePermission(Manifest.permission
//                        .READ_PHONE_STATE);

                boolean isCanUsePrivacy = !ADUtil.isFirstDayUseAd();
                SZUtil.logError("优量汇-是否可使用读取设备权限："+isCanUsePrivacy);
                GlobalSetting.setAgreeReadDeviceId(isCanUsePrivacy);
                GlobalSetting.setAgreeReadAndroidId(isCanUsePrivacy);
                GlobalSetting.setAgreePrivacyStrategy(isCanUsePrivacy);
                GlobalSetting.setEnableCollectAppInstallStatus(isCanUsePrivacy);
                GlobalSetting.setPersonalizedState(isCanUsePrivacy?0:1);//优量汇个性化推荐广告开关，0为开启个性化推荐广告，1为屏蔽个性化推荐广告
                GDTAdSdk.init(context, gmCustomConfig.getAppId());
                //初始化成功回调
                callInitSuccess();
            }
        });
    }

    @Override
    public String getNetworkSdkVersion() {
        return SDKStatus.getIntegrationSDKVersion();
    }
    @Override
    public String getAdapterSdkVersion() {
        return "1.0.0";
    }

}
